package cn.itcast.oriented.Object_

import java.text.SimpleDateFormat
import java.util.Date

/**
  * @Package cn.itcast.oriented.Object_
  * @author KTL
  * @date 2021/5/22 0022 12:19
  * @version V1.0
  * @Copyright © 2015-04-29  One for each, and two for each
  */
class ObjectDemo03 {}

/**
  * 使用object的特性（可以实现static）来实现工具类
  * 自定义格式化工具类
  */

object TimeUtils{
  def format(data:Date,pattern:String):String={
      val sdf = new SimpleDateFormat(pattern)
      val formatDate: String = sdf.format(data)
    formatDate
  }
}

object  Test{
  def main (args: Array[String] ): Unit = {
    val result: String = TimeUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss")
    println(result)
  }
}
